<template>
<div>
  <h1>详情页面</h1>
  评论<input type="text" v-model="form.text">
  <button @click="add">确认</button>

  <table>
    <tr>
      <td>标题</td>
      <td>内容</td>
    </tr>
    <tr>
      <td>{{list.title}}</td>
      <td>{{list.text}}</td>
    </tr>
  </table>

</div>
</template>

<script>
export default {
  name: "apl",
  data(){
    return{
      form:{news:this.$route.query.id,userid:localStorage.getItem('userid')},
      list:[],
      news:this.$route.query.id
    }
  },
  methods:{
    add(){
      this.$axios.post('users/Anews_API/',this.form)
      .then(i=>{
        if (i.data.code ==200){
          alert('评论成功')
        }
        else {
          alert('评论失败')
        }
      })
    },
    show(){
      this.$axios.get('users/Anews_API/?news='+this.news+'&userid='+this.form.userid)
      .then(i=>{
        this.list = i.data.list
      })

    }
  },
  mounted() {
    this.show()
  }
}
</script>

<style scoped>

</style>
